package com.letou.ls.view;


import com.letou.ls.R;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;
import android.widget.TextView;


public class ColorButton extends RelativeLayout {
    private TextView iv_corlor;
    private TextView tv_name;

    public ColorButton(Context context) {
        this(context, null);
    }
    
    public ColorButton(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }
    
    public ColorButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
    
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        LayoutInflater inflater = LayoutInflater.from(getContext());
        RelativeLayout view =
                (RelativeLayout) inflater.inflate(R.layout.view_colore_select_button, this);
        iv_corlor = (TextView) view.findViewById(R.id.iv_corlor);
        
        tv_name = (TextView) view.findViewById(R.id.tv_name);
    }
    
    public void setItemCorlor(String colorString) {
        int colorId = Color.parseColor(colorString);
        this.setTag(colorString);
        iv_corlor.setBackgroundColor(colorId);
    }
    
    public void setText(String msg) {
        tv_name.setText(msg);
    }
}
